<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $table_name = 'users';
        Schema::create($table_name, function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('tenant_id')->index()->comment('租户ID');
            $table->string('phone', 20)->default('')->comment('手机号码');
            $table->string('nickname', 50)->default('')->comment('昵称');
            $table->string('realname', 50)->default('')->comment('真实姓名');
            $table->string('avatar_url')->default('')->comment('头像地址');
            $table->string('weapp_openid')->comment('小程序OPENID');
            $table->tinyInteger('gender')->default(1)->comment('性别:1=男,2=女');
            $table->boolean('is_member')->default(false)->comment('是否会员');
            $table->timestamp('member_expired_time')->nullable()->comment('会员时卡过期时间');
            $table->integer('member_remain_times')->default(0)->comment('会员次卡剩余次数');
            $table->timestamps();
        });
        add_table_comment($table_name, '用户表');
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
